package jdbc;

import com.mysql.cj.x.protobuf.MysqlxDatatypes;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class Test1 {
    public static void main(String[] args) {
        try(
                Connection con = DBUtil.getConnection();
                ) {
            Scanner sc=new Scanner(System.in);
            System.out.println("请输入标题");
            String getTitle=sc.nextLine();
            System.out.println("请输入正文");
            String getContent=sc.nextLine();
            String sql="INSERT INTO article(title,content) VALUES(?,?)";
            PreparedStatement ps=con.prepareStatement(sql);
            ps.setString(1,getTitle);
            ps.setString(2,getContent);
            int i=ps.executeUpdate();
            if (i>0){
                System.out.println("插入成功");
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }

    }
}
